(function(){

if(!window.jaw){
    jaw = {media:{}};
}else if(!jaw.media){
    jaw.media = {};
}

jaw.media.addEventListener = function(elem, type, handle){
    if (elem.addEventListener){
        elem.addEventListener(type, handle, false);
    }else if (elem.attachEvent)
        elem.attachEvent("on" + type, handle);
}

jaw.getSWFObject = function(swfFlag){
    if(window.ActiveXObject)
        return window[swfFlag];
    else 
        return document[swfFlag];
}

jaw.dateFormat = function(date){
    var t = "00:00:00";
    if(date.constructor == Date){
        var hh = 8 - date.getHours();
        hh = hh < 10 ? "0" + hh : hh;
        var mm = date.getMinutes();
        mm = mm < 10 ? "0" + mm : mm;
        var ss = date.getSeconds();
        ss = ss < 10 ? "0" + ss : ss;
        t = hh + ":" + mm + ":" + ss;
    }
    return t;
}
})();

function sendUserPlayTime(){
    var swfObj = jaw.getSWFObject("media_photo");
    if(swfObj){
        var userTimeString = swfObj.userTime(), strArr = userTimeString.split(",");
        if(strArr.length == 3){
            var media_id=strArr[0], playTime = strArr[1], totalTime= strArr[2];
            //var spt = jaw.dateFormat(new Date(+playTime));
            //var tpt = jaw.dateFormat(new Date(+totalTime));
            var url = window.location.href;
            (new Image).src = "http://stat.stock.sohu.com/isp.gif?id=" + media_id + "&r=" + url + "&p=" + playTime + "&t=" + totalTime;
        }        
    }
}
jaw.media.addEventListener(window, 'beforeunload', sendUserPlayTime);